package com.jh.user.repository;

import com.jh.user.pojo.Channel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Repository
public interface ChannelRepository extends JpaRepository<Channel,String>,JpaSpecificationExecutor<Channel>{


	@Query("select channel from  Channel channel where channel.channelTag=:tag ")
	Channel findChannelByTag(@Param("tag") String tag);


	@Query("select channel from  Channel channel where channel.id=:id ")
	Channel findChannelById(@Param("id") long id);

	@Query("select channel from Channel channel where channel.channelNo=:channelNo")
	List<Channel> findChannelByChannelNo(@Param("channelNo") String channelNo);


	Channel findById(long channelId);

	@Query("select channel from Channel channel where channel.id in :channelIds")
	List<Channel> findChannel(@Param("channelIds") List<Long> channelIds);

	@Query("select channel from Channel channel where channel.channelNo=:channelNo ")
	Channel findChannelChannelNo(@Param("channelNo") String channelNo);

	@Query("select c from Channel c where c.channelTag = :channelProductCode")
    Channel findByChannelTag(@Param("channelProductCode") String channelProductCode);

	List<Channel> findByChannelNoIn(List<String> channelNo);
}
